Skip to content

fix(sourcemaps): Prevent Debug ID collisions#3356

Merged
szokeasaurusrex merged 4 commits into
masterfrom
szokeasaurusrex/fix-empty-sourcemaps
Jul 17, 2026
Merged

fix(sourcemaps): Prevent Debug ID collisions#3356
szokeasaurusrex merged 4 commits into
masterfrom
szokeasaurusrex/fix-empty-sourcemaps

Conversation

@szokeasaurusrex

Copy link
Copy Markdown
Member

Generate Debug IDs from both the generated JS bytes and the sourcemap bytes when a sourcemap is available. This keeps distinct JS files from sharing a Debug ID when their maps are byte-identical, while preserving existing IDs already present in JS or sourcemaps.

Add a regression test for identical empty maps with distinct JS inputs. Update the sourcemaps inject snapshots because the injected Debug IDs and embedded source map payloads now change for every affected case.

Fixes #3350
Fixes CLI-341

@szokeasaurusrex
szokeasaurusrex requested a review from a team as a code owner July 6, 2026 09:01
@linear-code

linear-code Bot commented Jul 6, 2026

Copy link
Copy Markdown

CLI-341

@szokeasaurusrex
szokeasaurusrex requested a review from JPeer264 July 6, 2026 09:02
Generate Debug IDs from both the generated JS bytes and the sourcemap bytes when a sourcemap is available. This keeps distinct JS files from sharing a Debug ID when their maps are byte-identical, while preserving existing IDs already present in JS or sourcemaps.

Add a regression test for identical empty maps with distinct JS inputs. Update the sourcemaps inject snapshots because the injected Debug IDs and embedded source map payloads now change for every affected case.

Fixes #3350
Fixes [CLI-341](https://linear.app/getsentry/issue/CLI-341/sentry-cli-mapping-identical-empty-source-maps-to-same-debug-id)
@szokeasaurusrex
szokeasaurusrex force-pushed the szokeasaurusrex/fix-empty-sourcemaps branch from a3465c5 to 3f96f9f Compare July 6, 2026 09:02
@szokeasaurusrex

Copy link
Copy Markdown
Member Author

@JPeer264 this change is needed to fix #3350, but it also will change all the debug IDs (i.e. the same sourcemap/minified file pair in the previous version will have a different debug ID after this update is released).

I am assuming that this is okay, but are you aware of any situation where this could break the product?

szokeasaurusrex added a commit that referenced this pull request Jul 6, 2026
Bump pinned GitHub-hosted runner labels to the newest GA images from actions/runner-images.

Also switch the OpenSSL bottle tag to tahoe so the x86_64 macOS 26 jobs can fetch bottles correctly.

Ref #3356
szokeasaurusrex added a commit that referenced this pull request Jul 6, 2026
Bump pinned GitHub-hosted runner labels to the newest GA images from actions/runner-images.

Use the x86_64 Homebrew command under Rosetta to fetch the Tahoe OpenSSL bottle for the macOS 26 jobs.

Ref #3356
szokeasaurusrex added a commit that referenced this pull request Jul 6, 2026
Bump pinned GitHub-hosted runner labels to the newest GA images from actions/runner-images.

Use the x86_64 Homebrew command under Rosetta to fetch the Tahoe OpenSSL bottle for the macOS 26 jobs.

Ref #3356

@JPeer264 JPeer264 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should be alright

szokeasaurusrex added a commit that referenced this pull request Jul 6, 2026
Bump pinned GitHub-hosted runner labels to the newest GA images from
actions/runner-images.

This updates Windows jobs to windows-2025 and macOS jobs to macos-26
while keeping Ubuntu on 24.04, which is still the newest GA Ubuntu
label.

Ref #3356
@szokeasaurusrex
szokeasaurusrex enabled auto-merge (squash) July 17, 2026 09:54

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6fc203f. Configure here.

Comment thread src/utils/sourcemaps.rs
inject::debug_id_from_js_and_sourcemap_bytes_hashed(
source_file.contents.as_slice(),
sourcemap_file.contents.as_slice(),
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shared map Debug IDs nondeterministic

Medium Severity

When multiple JS files explicitly reference the same external sourcemap without a Debug ID, the new hash includes the first processed JS file’s bytes. Because sourcemap_references is iterated as a HashMap, that “first” file can change across runs, so the written Debug ID is no longer stable for the same inputs.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6fc203f. Configure here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably not a very common occurrence in the real world. We are therefore choosing not to address this unless we receive a bug report

@szokeasaurusrex
szokeasaurusrex merged commit ecb5dd0 into master Jul 17, 2026
31 checks passed
@szokeasaurusrex
szokeasaurusrex deleted the szokeasaurusrex/fix-empty-sourcemaps branch July 17, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sentry CLI mapping identical empty source maps to same debug ID

3 participants